import alibabacloud_oss_v2 as oss

# 硬编码参数值（与uploads.py保持一致）
region = 'cn-beijing'
bucket = 'whatteam1'
# key = 'a.png'

# 硬编码凭证信息（与uploads.py相同）
access_key_id = "LTAI5tC4VPs9n2ZoLy8sptqR"
access_key_secret = "Gr6QeyWXCuwhTVVUk25x8FTTMLunwv"

def main(key:str):
    # 使用静态凭证信息
    credentials_provider = oss.credentials.StaticCredentialsProvider(
        access_key_id=access_key_id,
        access_key_secret=access_key_secret
    )

    # 加载SDK配置
    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = region

    # 创建OSS客户端
    client = oss.Client(cfg)

    # 执行删除操作
    result = client.delete_object(oss.DeleteObjectRequest(
        bucket=bucket,
        key=key,
    ))

    # 输出完整结果信息
    print(f'Delete successful! Target: {bucket}/{key}')
    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' version id: {result.version_id},'
          f' delete marker: {result.delete_marker}'
          )

if __name__ == "__main__":
    main()
